package com.mediatek.contacts.ext;

import android.app.Fragment;
import android.app.FragmentManager;
import android.content.Intent;
import android.content.Context;
import android.net.Uri;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.ListView;

import com.android.contacts.common.model.RawContact;
import com.android.contacts.common.model.RawContactDelta;
import com.google.common.collect.ImmutableList;

/**
 * for op01 plugin
 */
public interface IRcsExtension {
    //---------------------for Multi Choise-------------------//
    /**
     * OP01 RCS will filter phone number in phone Multi Choise list.
     * let the op01 get intent data from host set.
     * @param intent data from caller
     */
    void getIntentData(Intent intent);

    /**
     * OP01 RCS will filter phone number in phone Multi Choise list.
     * set the exist numbers for filter,not show in list.
     * @param query selection 
     */
    void setListFilter(StringBuilder selection);

    /**
     * OP01 RCS will config phone Multi Choise list Uri.
     * remove duplicate number in list.
     * @param query uri 
     */
    Uri configListUri(Uri uri);

    /**
     * OP01 RCS will add menu item in phone Multi Choise list, eg:group.
     * mark item for selected group in phone numbers list.
     * @param list menu and list context 
     */
    void addListMenuOptions(Context context, Menu menu);

    /**
     * OP01 RCS will mark item for selected group in phone numbers list.
     * get data ids from selected group and mark item in list.
     * @param list fragment and data ids 
     */
    void getGroupListResult(Fragment fragment, long[] ids);

    /**
     * OP01 RCS custom search button in action bar.
     * search button is invisible in phone numbers list.
     * @param search menu item 
     */
    void customSearchInActionBar(MenuItem item);

    //-----------------------------for group------------------//
    /**
     * OP01 RCS will add group menu item
     * custom group menu and show in action bar.
     * @param menu: group menu
     * @param context: group activity context
     */
    void addGroupMenuOptions(Menu menu, Context context);

     //-----------------------------for editor------------------//
     /**
     * OP01 RCS will listen phone number text change.
     * if query same phone number, show popup list view for choose.
     * @param editor view ,state and input content 
     */
    void setTextChangedListener(RawContactDelta state, EditText view, int inputType, String number);

     /**
     * OP01 RCS will close listener of phone number text change.
     * close popup list and destroy search engine.
     * @param true:quit search engine, false:only close popup popup list
     */
    void closeTextChangedListener(boolean quit);

    /**
     * OP01 RCS will set currnet editor fragment and it's manager.
     * @param editor fagment and fagment manager
     */
    void setEditorFragment(Fragment fragment, FragmentManager manager);

    //--------------for PeopleActivity----------------//
    /**
     * OP01 RCS will add menu item in PeopleActivity
     * @param people menu
     */
    public void addPeopleMenuOptions(Menu menu);

    /**
     * OP01 RCS will go to personal profile activity, once clicked profile item.
     * @param uri. contact lookup uri.
     * @param isEmpty. is current profile is empty.
     * @return 1: is profile, and listentenr set sucess. 0. listener set unsucessful
     */
    boolean addRcsProfileEntryListener(Uri uri, boolean isEmpty);

    /**
     * OP01 RCS will add public account entry to people list.
     * @param listView. list view of contact info
     */
    void createPublicAccountEntryView(ListView listView);

    //--------------for QuickContact----------------//
    /**
     * OP01 RCS will go to contact detail activity, update photo from rcs server.
     * @param lookupUri. contact lookup uri.
     * @param photo. Contact photoView.
     */
    void updateContactPhotoFromRcsServer(Uri lookupUri, ImageView photo, Context context);


    /**
     * OP01 RCS remove rich communication Suite account.
     * @param rawContacts. original rawContacts list.
     * @return cofigured rawContacts list.
     */
    ImmutableList<RawContact> rcsConfigureRawContacts(ImmutableList<RawContact> rawContacts);

    /**
     * OP01 RCS will get photo from rcs server, and refresh thumbnail Photo.
     * @param isLetterTile. letter photo or thumbnail Photo.
     * @param hasThemeColor. Theme Color has set or not.
     * @return true or false.
     */
    boolean needUpdateContactPhoto(boolean isLetterTile, boolean hasThemeColor);

    /**
     * Used in RCS to custom ContactListItemView in People List.
     */
    public interface ContactListItemRcsView {
        /**
         * The view contains a icon.
         * @param contactId contactId
         * @return ImageView contains joyn icon
         */
        View createCustomView(long contactId);

        /**
         * onMeasure.
         * @param widthMeasureSpec width MeasureSpec
         * @param heightMeasureSpec height MeasureSpec
         */
        void onMeasure(int widthMeasureSpec, int heightMeasureSpec);

        /**
         * onLayout.
         * @param changed changed
         * @param leftBound left Bound
         * @param topBound top Bound
         * @param rightBound right Bound
         * @param bottomBound bottom Bound
         */
        void onLayout(boolean changed, int leftBound, int topBound, int rightBound, int bottomBound);
    }

    /**
     * Used to add Joyn icon on the left top in QuickActivity.
     *
     */
    public interface QuickContactRcsScroller {
        /**
         * create Rcs Icon View.
         * @param container A FrameLayout placed on the left top.
         * @param anchorView the NameView
         * @param lookupUri Contact uri
         * @return ImageView contains joyn icon
         */
        View createRcsIconView(View container, View anchorView, Uri lookupUri);

        /**
         * update Rcs contact.
         * @param lookupUri Contact uri
         */
        void updateRcsContact(Uri lookupUri);

        /**
         * update the ImageView visiblity when scroll.
         */
        void updateRcsIconView();
    }

    /**
     *
     * @return get the object for custom ContactListItemView
     */
    ContactListItemRcsView getContactListItemRcsView();

    /**
     * @return get the object for custom MultiShrinkScroller
     */
    QuickContactRcsScroller getQuickContactRcsScroller();

}
